//
//  DestFirstCellInfoViewController.m
//  TravelEveryDay
//
//  Created by dlios on 15/10/19.
//  Copyright © 2015年 com.lanou3g. All rights reserved.
//

#import "DestFirstCellInfoViewController.h"
#import "BaseHeader.h"
#import "DestImpressionModel.h"
#import "DestImpressionsFristTableViewCell.h"
#import "DestImpressionsSecondTableViewCell.h"
#import "DestImpressionSecondModel.h"
#import "DestBasicModel.h"
#import "DestBasicTableViewCell.h"
#import "DestTravelNotesViewController.h"
#import <MessageUI/MessageUI.h>
#import "DestPhotoesViewController.h"
#import "DestWebViewViewController.h"
#import "RecUserViewController.h"
#import "GiFHUD.h"
@interface DestFirstCellInfoViewController ()<UITableViewDelegate,UITableViewDataSource,UIAlertViewDelegate>
@property(nonatomic,strong)UIView *destTabbleViewHeaderView;
@property(nonatomic,strong)UIView *destTableViewFooterView;
@property(nonatomic,strong)UITableView *destFooterTableView;
@property (nonatomic,strong)UITableView * destTabelView;
@property(nonatomic,strong)UIImageView *destHostImageView;
@property(nonatomic,strong)NSString *HeaderImageViewString;//头部图片的网址
@property(nonatomic,strong)UIImageView *destPhtotoesImageView;
@property(nonatomic,strong)UILabel *photoCountLabel;
@property(nonatomic,strong)NSNumber *photoCountString;//图片个数
@property(nonatomic,strong)UIImageView *destTreeImageView;
@property (nonatomic,strong)UILabel *destNameLabel;
@property(nonatomic,strong)NSString *destNameString;///显示数下面name的字符串;
@property(nonatomic,strong)UILabel *destReasonLabel;///显示名字下面的原因小字的label;
@property(nonatomic,strong)NSString  *destReasonString;
@property(nonatomic,strong)UILabel *hotLabel;//显示面包印象的label;
@property(nonatomic,strong)NSMutableArray *destImpressionsModelArray;//装印象的数组
@property(nonatomic,assign)CGFloat hiehgt;///没图的cell的自定义高度
@property(nonatomic,strong)NSMutableArray *destReviewsModelArray;//脚视图上那个时有时无的tabelVeiw的model数组;
@property(nonatomic,assign)CGFloat footerTabelViewHeight;//脚部的高度
@property(nonatomic,strong)UIButton *destMoreButton;//更多印象button
@property (nonatomic,strong)UILabel * basicInfoLabel;//基本信息的label;

@property(nonatomic,strong) UILabel *basicLeftLabel;
@property(strong,nonatomic) UILabel *basicLeftCircleLabel;
@property(strong,nonatomic) UILabel *basicRightLabel;
@property(strong,nonatomic) UILabel *basicRightCircleLabel;
@property (strong,nonatomic)UITableView *destLastTabelView;

@property(strong,nonatomic)NSMutableArray *destLastTableViewModelArryay;


@property(assign,nonatomic)CGFloat destLastTabelViewheight;

@property(assign,nonatomic)NSInteger more;///是最下面的tabelView的线的显示的判断条件 为了记录哪个数据是@""的类型 下一个cell上的头线给隐藏了
@property(strong,nonatomic)NSNumber *pushToId;
@property(strong,nonatomic)NSNumber *PushToType;


@property(strong,nonatomic)UIWebView *webView;  //系统打电话;
@property(strong,nonatomic)UIAlertView *alertView;

@end

@implementation DestFirstCellInfoViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];
    self.navigationController.navigationBarHidden = YES;
    self.automaticallyAdjustsScrollViewInsets = NO;
    self.tabBarController.tabBar.hidden = YES;
    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    button.frame =CGRectMake(5, 20, 30, 30);
    [button setImage:[UIImage imageNamed:@"play-jiantouzuo.png"] forState:UIControlStateNormal];
    [button addTarget:self action:@selector(back) forControlEvents:UIControlEventTouchUpInside];
    
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]initWithCustomView:button];
    _destImpressionsModelArray = [[NSMutableArray alloc]init];
    _destReviewsModelArray  =[[NSMutableArray alloc]init];//脚视图上那个时有时无的tabelVeiw的model数组;chushihua;
    _destLastTableViewModelArryay = [[NSMutableArray alloc]init];
    _more = 1000;
    [self createTableView];
    [self crecteTabelViewHeader];
    [self createBackButton];
    [self getDestData];
}
#pragma mark - 创建tableView
- (void)createTableView {
    _destTabelView = [[UITableView  alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT )];
    _destTabelView.delegate =  self;
    _destTabelView.dataSource = self;
    [_destTabelView setSeparatorStyle:UITableViewCellSeparatorStyleNone];
    [self.view addSubview:_destTabelView];
}
#pragma mark  - 创建头部
- (void)crecteTabelViewHeader {
    _destTabbleViewHeaderView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 430 *HEIGHT)];///创建的头部view
    _destHostImageView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 280 *HEIGHT)];///创建的大图
    NSURL *url = [NSURL URLWithString:_HeaderImageViewString];
    [_destHostImageView sd_setImageWithURL:url placeholderImage:PLACEHOLDERIMAGE];
    
    _destPhtotoesImageView = [[UIImageView alloc]initWithFrame:CGRectMake(SCREEN_WIDTH - 80*WIDTH, 250 *HEIGHT, 20*WIDTH, 20*HEIGHT)];
    _destPhtotoesImageView.image  =[UIImage imageNamed:@"Desticonfont-photo.png"];///创建的相机的图
    _photoCountLabel = [[UILabel alloc]initWithFrame:CGRectMake(SCREEN_WIDTH - 58*WIDTH , 250 *HEIGHT, 75 *WIDTH, 20 * WIDTH)];///创建的相机后面个数的label;
    _photoCountLabel.textAlignment = NSTextAlignmentLeft;
    _photoCountLabel.textColor = [UIColor whiteColor];
    UIImageView *destBackImageView = [[UIImageView alloc]initWithFrame:CGRectMake((SCREEN_WIDTH - 50)/2, 255 *HEIGHT, 50 *HEIGHT, 50 *HEIGHT)];///创建显示数北京白色的图片
    destBackImageView.layer.cornerRadius = 25 *HEIGHT;
    destBackImageView.layer.masksToBounds = YES;
    destBackImageView.image = [UIImage imageNamed:@"destavatar_bg.png"];
    _destTreeImageView = [[UIImageView alloc]initWithFrame:CGRectMake((SCREEN_WIDTH - 30)/2, 265 *HEIGHT, 30 *HEIGHT, 30 *HEIGHT)];///创建显示图片的图;
    _destTreeImageView.layer.cornerRadius = 15 *HEIGHT;
    _destTreeImageView.layer.masksToBounds = YES;
    _destTreeImageView.image = [UIImage imageNamed:@"destAttraction.png"];
    _destNameLabel = [[UILabel alloc]initWithFrame:CGRectMake((SCREEN_WIDTH - 300*WIDTH)/2, 310 * HEIGHT, 300 *WIDTH, 40 *HEIGHT)];//显示树下面的名字的label;
    _destNameLabel.textColor = [UIColor blackColor];
    _destNameLabel.font = [UIFont boldSystemFontOfSize:19.0f];
    _destNameLabel.textAlignment = NSTextAlignmentCenter;
    //    _destNameLabel.text = _destNameString;
    ///设置显示名字下面的小子reason的label;
    _destReasonLabel = [[UILabel alloc]initWithFrame:CGRectMake(_destNameLabel.frame.origin.x, 350 *HEIGHT, 300 *WIDTH, 20 *HEIGHT)];
    _destReasonLabel.textAlignment = NSTextAlignmentCenter;
    _destReasonLabel.textColor = [UIColor blackColor];
    _destReasonLabel.font = [UIFont systemFontOfSize:12.0f];
    [_destHostImageView addSubview:_photoCountLabel];
    [_destHostImageView addSubview:_destPhtotoesImageView];
    [_destTabbleViewHeaderView addSubview:_destHostImageView];
    [_destTabbleViewHeaderView addSubview:destBackImageView];
    [_destTabbleViewHeaderView addSubview:_destTreeImageView];
    [_destTabbleViewHeaderView addSubview:_destNameLabel];
    [_destTabbleViewHeaderView  addSubview:_destReasonLabel];
    _destTabelView.tableHeaderView = _destTabbleViewHeaderView;
    
}
#pragma mark  -创建面包印象的方法
- (void)createDestbridelaebl {
    _hotLabel = [[UILabel alloc]initWithFrame:CGRectMake((SCREEN_WIDTH - 100)/2, 380 *HEIGHT    , 100, 30 *HEIGHT)];
    _hotLabel.textAlignment = NSTextAlignmentCenter;
    UILabel *leftLabel = [[UILabel alloc]initWithFrame:CGRectMake(70*WIDTH, 395 *HEIGHT , 50 *WIDTH, 2 *HEIGHT)];
    leftLabel.backgroundColor = [UIColor lightGrayColor];
    UILabel *circleLabel = [[UILabel alloc]initWithFrame:CGRectMake(leftLabel.frame.size.width +leftLabel.frame.origin.x +3 *WIDTH, 394 *HEIGHT , 4*HEIGHT, 4*HEIGHT)];
    circleLabel.layer.cornerRadius = 2 *HEIGHT;
    circleLabel.layer.masksToBounds = YES;
    circleLabel.backgroundColor = [UIColor lightGrayColor];
    UILabel *rightLabel = [[UILabel alloc]initWithFrame:CGRectMake(SCREEN_WIDTH - 120* WIDTH,395 *HEIGHT , 50 * WIDTH, 2 * HEIGHT)];
    rightLabel.backgroundColor = [UIColor lightGrayColor];
    UILabel *circleRightLabel = [[UILabel alloc]initWithFrame:CGRectMake(rightLabel.frame.origin.x - 7*WIDTH, 394*HEIGHT , 4 *HEIGHT, 4 *HEIGHT)];
    circleRightLabel.layer.cornerRadius = 2 *HEIGHT;
    circleRightLabel.layer.masksToBounds = YES;
    circleRightLabel.backgroundColor = [UIColor lightGrayColor];
    [_destTabbleViewHeaderView addSubview:circleRightLabel];
    [_destTabbleViewHeaderView addSubview:rightLabel];
    [_destTabbleViewHeaderView addSubview:circleLabel];
    [_destTabbleViewHeaderView addSubview:leftLabel];
    [_destTabbleViewHeaderView addSubview:_hotLabel];
    
}
#pragma mark - 给头视图加数据
- (void)setDestHeaderdata {
    NSURL *url = [NSURL URLWithString:_HeaderImageViewString];
    [_destHostImageView sd_setImageWithURL:url placeholderImage:PLACEHOLDERIMAGE];
    
    ///解决bug  为了让数据加载到本页 才能点击 进入下一页面
    if (_HeaderImageViewString == nil) {
        
    }else{
        _destHostImageView.userInteractionEnabled = YES;///用户交互
        UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(destHostImageViewTap)];
        [_destHostImageView addGestureRecognizer:tap];
    }
    
    
    _photoCountLabel.text = [NSString stringWithFormat:@"%@",_photoCountString];
    _destReasonLabel.text = _destReasonString;
    _hotLabel.text = @"面包印象";
}
#pragma mark -  创建返回按钮
- (void)createBackButton {
    UIButton *backButton =[UIButton buttonWithType:UIButtonTypeCustom];
    [backButton setImage:[UIImage imageNamed:@"play-jiantouzuo.png"] forState:UIControlStateNormal];
    backButton.frame =CGRectMake(16, 20, 30, 30);
    [backButton addTarget:self action:@selector(back) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:backButton];
}
#pragma mark - 创建 tableView的脚视图
- (void)createTabelViewFooterView {
    _destTableViewFooterView = [[UIView alloc]initWithFrame:CGRectZero];
    [self.view addSubview:_destTableViewFooterView];
    _destFooterTableView = [[UITableView alloc]initWithFrame:CGRectZero];
    _destFooterTableView.delegate =self;
    _destFooterTableView.dataSource = self;
    [_destFooterTableView setSeparatorStyle:UITableViewCellSeparatorStyleNone];
    [_destTableViewFooterView addSubview:_destFooterTableView];
    //创建更多地button;
    [self creatFooterMoreButton];
    //创建基本信息的label;
    [self creatFooterbasicInfoLabel];
    //创建 最后的tabelView
    _destLastTabelView = [[UITableView alloc]initWithFrame:CGRectZero];
    _destLastTabelView.delegate = self;
    _destLastTabelView.dataSource = self;
    [_destLastTabelView setSeparatorStyle:UITableViewCellSeparatorStyleNone];
    [_destTableViewFooterView addSubview:_destLastTabelView];
    
}
#pragma mark - 创建更多地button
- (void)creatFooterMoreButton {
    _destMoreButton = [UIButton buttonWithType:UIButtonTypeCustom];
    _destMoreButton.titleLabel.font = [UIFont systemFontOfSize:15.];
    _destMoreButton.frame = CGRectZero;
    [_destMoreButton setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal];
    _destMoreButton.layer.cornerRadius = 15 *HEIGHT;
    _destMoreButton.layer.borderWidth = 0.5;
    _destMoreButton.layer.borderColor = [UIColor lightGrayColor].CGColor;
    _destMoreButton.layer.masksToBounds = YES;
    //    [_destMoreButton addTarget:self action:@selector(moreButtonClick) forControlEvents:UIControlEventTouchUpInside];
    [_destTableViewFooterView  addSubview:_destMoreButton];
}
#pragma mark - 创建基本信息的label
- (void)creatFooterbasicInfoLabel {
    _basicInfoLabel = [[UILabel alloc]initWithFrame:CGRectZero];
    _basicInfoLabel.textAlignment = NSTextAlignmentCenter;
    _basicInfoLabel.font = [UIFont systemFontOfSize:18.];
    _basicLeftLabel = [[UILabel alloc]initWithFrame:CGRectZero];
    _basicLeftLabel.backgroundColor = [UIColor lightGrayColor];
    _basicLeftCircleLabel = [[UILabel alloc]initWithFrame:CGRectZero];
    _basicLeftCircleLabel .layer.cornerRadius = 2 *HEIGHT;
    _basicLeftCircleLabel .layer.masksToBounds = YES;
    _basicLeftCircleLabel.backgroundColor = [UIColor lightGrayColor];
    _basicRightLabel = [[UILabel alloc]initWithFrame:CGRectZero];
    _basicRightLabel.backgroundColor = [UIColor lightGrayColor];
    _basicRightCircleLabel = [[UILabel alloc]initWithFrame:CGRectZero];
    _basicRightCircleLabel.layer.cornerRadius = 2 *HEIGHT;
    _basicRightCircleLabel.layer.masksToBounds = YES;
    _basicRightCircleLabel.backgroundColor = [UIColor lightGrayColor];
    [_destTableViewFooterView addSubview:_basicRightCircleLabel];
    [_destTableViewFooterView addSubview:_basicRightLabel];
    [_destTableViewFooterView addSubview:_basicLeftCircleLabel];
    [_destTableViewFooterView addSubview:_basicLeftLabel];
    [_destTableViewFooterView addSubview:_basicInfoLabel];
}
#pragma mark - 给脚视图 赋值 和 大小
- (void)setFooterViewData {
    
    
    _destFooterTableView.frame = CGRectMake(0, 0, SCREEN_WIDTH, _footerTabelViewHeight  );
    
    [_destMoreButton addTarget:self action:@selector(moreButtonClick) forControlEvents:UIControlEventTouchUpInside];
    _destMoreButton.frame = CGRectMake((SCREEN_WIDTH - 250 * WIDTH) / 2, _footerTabelViewHeight +25 *HEIGHT, 250 * WIDTH, 35 *HEIGHT);
    //    }
    
    [_destMoreButton setTitle:@"更多印象" forState:UIControlStateNormal];
    ///基本信息的那几个label的赋值 以及大小
    [self setBasicLabelData];
    //给tablevIEW赋值 大小的计算
    for (DestBasicModel *model in _destLastTableViewModelArryay) {
        
        if ([model.secondString isEqualToString:@""]) {
            
        }else{
            CGFloat BasicHight =[StringWithHeight heightWithText:model.secondString width:SCREEN_WIDTH - 20 *WIDTH font:[UIFont systemFontOfSize:13.0]];
            _destLastTabelViewheight = (_destLastTabelViewheight+ 30 + BasicHight ) ;
        }
    }
    
    _destLastTabelView.frame = CGRectMake( 0, _footerTabelViewHeight + 135 *HEIGHT , SCREEN_WIDTH, _destLastTabelViewheight );
    _destTableViewFooterView.frame = CGRectMake(0, 0, SCREEN_WIDTH, _footerTabelViewHeight + 180 *HEIGHT + _destLastTabelViewheight  );
    _destTabelView.tableFooterView = _destTableViewFooterView;//设置脚视图大小
    
}
#pragma mark - 基本信息的那几个label的赋值 以及大小
- (void)setBasicLabelData {
    _basicInfoLabel.frame = CGRectMake((SCREEN_WIDTH - 100)/2, _footerTabelViewHeight +35 *HEIGHT + 60 *HEIGHT, 100, 30 * HEIGHT);
    _basicInfoLabel.text = @"基本信息";
    
    _basicLeftLabel.frame = CGRectMake(70 * WIDTH, _basicInfoLabel.frame.origin.y + 14 *HEIGHT, 50 *WIDTH, 2 *HEIGHT);
    
    _basicLeftCircleLabel.frame = CGRectMake(123 * WIDTH, _basicInfoLabel.frame.origin.y + 13 *HEIGHT, 4*HEIGHT, 4*HEIGHT);
    
    _basicRightLabel.frame = CGRectMake(SCREEN_WIDTH - 120* WIDTH,_basicLeftCircleLabel.frame.origin.y , 50 * WIDTH, 2 * HEIGHT);
    
    _basicRightCircleLabel.frame  = CGRectMake(_basicRightLabel.frame.origin.x - 7,_basicInfoLabel.frame.origin.y + 12 *HEIGHT, 4*HEIGHT, 4*HEIGHT);
    
}

#pragma mark - 请求数据
- (void)getDestData {
    
    
    [DestAFNDataBlock string:[NSString stringWithFormat:@"http://api.breadtrip.com/destination/place/%@/%@/",_type,_MyId] AFNData:^(id block) {
        
        //首先给最顶上的图片赋值
        NSMutableArray *hottest_placesArray = [block objectForKey:@"hottest_places"];
        if (hottest_placesArray.count == 0) {
            
        }else{
            _HeaderImageViewString = [[hottest_placesArray objectAtIndex:0]objectForKey:@"photo"];
        }
        _photoCountString = [block objectForKey:@"photo_count"];
        
        
        if (![[block objectForKey:@"recommended_reason"] isKindOfClass:[NSNull class]]) {
            
            _destReasonString = [block objectForKey:@"recommended_reason"];
        }else{
            _destNameString = @"";
        }
        ///主要的tabelView赋值语句
        NSMutableDictionary *impressionsDic = [block objectForKey:@"impressions"];
        NSMutableArray *tripsArray = [impressionsDic objectForKey:@"trips"];
        for (NSMutableDictionary * tripsDic in tripsArray) {
            DestImpressionModel *model = [DestImpressionModel modelWithDictionary:tripsDic];
            if ([model.trip_text isEqualToString:@""]) {
                model.trip_TextHeight = 0.0f;
            }else{
                model.trip_TextHeight =[StringWithHeight heightWithText:model.trip_text width:SCREEN_WIDTH - 10 *WIDTH font:[UIFont systemFontOfSize:13.0]];
            }
            [_destImpressionsModelArray addObject:model];
        }
        
        
        ///开始给tabelView的脚上的第一个tabeleView赋值的值
        NSMutableArray *reviewsArray = [impressionsDic objectForKey:@"reviews"];
        
        if (reviewsArray.count !=0) {
            for (NSMutableDictionary *reviewsDic in reviewsArray) {
                DestImpressionSecondModel *secondModel = [DestImpressionSecondModel modelWithDictionary:reviewsDic];
                if ([secondModel.content isEqualToString:@""]) {
                    secondModel.contentHeight = 0.0;
                    
                }else{
                    secondModel.contentHeight =[StringWithHeight heightWithText:[NSString stringWithFormat:@"^_^%@",secondModel.content] width:355* WIDTH font:[UIFont systemFontOfSize:13.0]];
                }
                _footerTabelViewHeight = _footerTabelViewHeight +secondModel.contentHeight +46 *HEIGHT;
                [_destReviewsModelArray addObject:secondModel];
            }
        }else{
            _footerTabelViewHeight = 0.0;
        }
        
        ///给最后的tableView的数组赋值
        ///给概况赋值
        DestBasicModel *descriptionModel = [[DestBasicModel alloc]init];
        descriptionModel.firstString = @"概况";
        if ([[block objectForKey:@"description"] isKindOfClass:[NSNull class]]) {
            descriptionModel.secondString = @"";
        }else{
            descriptionModel.secondString = [block  objectForKey:@"description"];
        }
        
        [_destLastTableViewModelArryay addObject:descriptionModel];
        
        ///给地址赋值
        DestBasicModel *addressModel = [[DestBasicModel alloc]init];
        addressModel.firstString = @"地址";
        if ([[block objectForKey:@"address"] isKindOfClass:[NSNull class]]) {
            addressModel.secondString = @"";
        }else{
            addressModel.secondString = [block objectForKey:@"address"];
        }
        [_destLastTableViewModelArryay addObject:addressModel];
        
        ///给到达方式赋值
        DestBasicModel * arrivalModel = [[DestBasicModel alloc]init];
        arrivalModel.firstString = @"到达方式";
        if ([[block objectForKey:@"arrival_type"] isKindOfClass:[NSNull class]]) {
            arrivalModel.secondString = @"";
        }else{
            arrivalModel.secondString = [block objectForKey:@"arrival_type"];
        }
        [_destLastTableViewModelArryay addObject:arrivalModel];
        
        ///给开放时间赋值
        DestBasicModel *openTimeModel = [[DestBasicModel alloc]init];
        openTimeModel.firstString = @"开放时间";
        if ([[block objectForKey:@"opening_time"] isKindOfClass:[NSNull class]]) {
            openTimeModel.secondString = @"";
        }else{
            openTimeModel.secondString = [block objectForKey:@"opening_time"];
        }
        [_destLastTableViewModelArryay addObject:openTimeModel];
        
        ///门票价格
        DestBasicModel *feeModel = [[DestBasicModel alloc]init];
        feeModel.firstString = @"门票价格";
        if ([[block objectForKey:@"fee"] isKindOfClass:[NSNull class]]) {
            feeModel.secondString =@"";
        }else {
            feeModel.secondString = [block objectForKey:@"fee"];
        }
        [_destLastTableViewModelArryay addObject:feeModel];
        ///练习方式
        DestBasicModel  *telModel =[[DestBasicModel alloc]init];
        telModel.firstString = @"联系方式";
        if ([[block objectForKey:@"tel"] isKindOfClass:[NSNull class]]) {
            telModel.secondString = @"";
        }else{
            telModel.secondString = [block objectForKey:@"tel"];
        }
        [_destLastTableViewModelArryay addObject:telModel];
        ///官网的数据
        DestBasicModel *websiteModel = [[DestBasicModel alloc]init];
        websiteModel.firstString = @"官方网站";
        if ([[block objectForKey:@"website"] isKindOfClass:[NSNull class]]) {
            websiteModel.secondString =@"";
        }else{
            websiteModel.secondString = [block objectForKey:@"website"];
        }
        [_destLastTableViewModelArryay addObject:websiteModel];
        
        
        //用于传值下一页;
        _pushToId = [block objectForKey:@"id"];
        _PushToType =[block objectForKey:@"handlingtype"];
        [self crecteTabelViewHeader];//创建透视图
        _destNameString = [block objectForKey:@"name"];
        _destNameLabel.text = _destNameString;
        self.title = _destNameString;
        [GiFHUD dismiss];
        [self createDestbridelaebl];//创建头视图的方法
        [self createTabelViewFooterView];//创建脚视图
        [self setDestHeaderdata];//给透视图赋值
        [self setFooterViewData];//给脚视图赋值
        [_destTabelView reloadData];
    } AFNData1:^(id block) {

        
    }];
}
#pragma mark - tabView的代理方法
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    
    if ([tableView isEqual:_destTabelView]) {
        return _destImpressionsModelArray.count;
    }else if ([tableView isEqual:_destFooterTableView]) {
        return _destReviewsModelArray.count;
    }else{
        return 7;
    }
}
#pragma mark - 返回cell的高度
- (CGFloat )tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    if ([tableView isEqual:_destTabelView]) {
        DestImpressionModel *model = [_destImpressionsModelArray objectAtIndex:indexPath.row];
        
        return (model.trip_TextHeight + 46 +170) *HEIGHT;
        
    }else if ([tableView isEqual:_destFooterTableView]) {
        DestImpressionSecondModel *secondModel = [_destReviewsModelArray objectAtIndex:indexPath.row];
        
        return secondModel.contentHeight +46 *HEIGHT;
    }else{
        DestBasicModel *basicModel = [_destLastTableViewModelArryay objectAtIndex:indexPath.row];
        ///判断数据 返回cell高度;
        if ([basicModel.secondString isEqualToString:@""]) {
            return 0.0;
        }else{
            CGFloat BasicHight =[StringWithHeight heightWithText:basicModel.secondString width:SCREEN_WIDTH - 20 *WIDTH font:[UIFont systemFontOfSize:13.0]];
            return 30*HEIGHT + BasicHight ;
        }
    }
    
}
#pragma mark - 返回cell种类
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    
    if ([tableView isEqual:_destTabelView]) {
        
        DestImpressionModel *model = [_destImpressionsModelArray objectAtIndex:indexPath.row];
        static NSString *firstCellId = @"firstcell";
        DestImpressionsFristTableViewCell * firstCell =[tableView dequeueReusableCellWithIdentifier:firstCellId];
        
        if (!firstCell) {
            firstCell = [[DestImpressionsFristTableViewCell alloc]initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:firstCellId];
            
        }
        
        ///头像点击
        firstCell.button.tag = indexPath.row;
        [firstCell.button addTarget:self action:@selector(imageViewtap:) forControlEvents:UIControlEventTouchUpInside];
        [firstCell setSelectionStyle:UITableViewCellSelectionStyleNone];
        firstCell.dataModel =model;
        
        return firstCell;
        
    }else if ([tableView isEqual:_destFooterTableView]){
        
        static NSString *secondCellId = @"secondCell";
        DestImpressionsSecondTableViewCell *secondCell = [tableView dequeueReusableCellWithIdentifier:secondCellId];
        
        if (!secondCell) {
            secondCell = [[DestImpressionsSecondTableViewCell alloc]initWithStyle:UITableViewCellStyleValue2 reuseIdentifier:secondCellId];
            
        }
        secondCell.ImageViewButton.tag = indexPath.row + 10000;
        ///头像点击的button
        [secondCell.ImageViewButton addTarget:self action:@selector(iamgeViewButtonClick:) forControlEvents:UIControlEventTouchUpInside];
        [secondCell setSelectionStyle:UITableViewCellSelectionStyleNone];
        DestImpressionSecondModel *secondModel = [_destReviewsModelArray objectAtIndex:indexPath.row];
        secondCell.dataModel = secondModel;
        
        return secondCell;
        
    }else{
        static NSString *basicCellId = @"basicCell";
        DestBasicTableViewCell *basicCell = [tableView dequeueReusableCellWithIdentifier:basicCellId];
        if (!basicCell) {
            basicCell = [[DestBasicTableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:basicCellId];
        }
        DestBasicModel *model = [_destLastTableViewModelArryay objectAtIndex:indexPath.row];
        //给cell 加 > 号的代码
        if (indexPath.row == 1 || indexPath.row == 5 || indexPath.row == 6) {
            //在这个cell上代> 号
            basicCell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
        }
        //把第一行头上的线去掉
        if (indexPath.row == 0) {
            basicCell.lineView.hidden = YES;
        }
        
        //判断数据 是否赋值
        if ([model.secondString isEqualToString:@""]) {
            
            NSInteger index = [_destLastTableViewModelArryay indexOfObject:model];
            ///判断给最上面的cell的线去掉的语句;
            _more = index;
            
        }else{
            basicCell.dataModel = model;
        }
        
        if (_more == 6) {
            
        }else{
            
            if (indexPath.row == _more +1) {
                basicCell.lineView.hidden = YES;
            }
        }
        [basicCell setSelectionStyle:0];
        
        return basicCell;
    }
}
#pragma mark  - tabelView代理方法 点击方法
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    if ([tableView isEqual:_destLastTabelView]) {
        DestBasicModel *basicModel = [_destLastTableViewModelArryay objectAtIndex:indexPath.row];
        
        
        switch (indexPath.row) {
            case 5:
            {
                _alertView = [[UIAlertView alloc]initWithTitle:@"是否拨打电话" message:  basicModel.secondString delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil];
                [_alertView show];
                
            }
                break;
            case 6:
            {
                DestWebViewViewController *destWebView = [[DestWebViewViewController alloc]init];
                destWebView.webStr = basicModel.secondString;
                destWebView.titleStr =  _destNameString;
                [self.navigationController pushViewController:destWebView animated:YES];
                
            }
                break;
            default:
                break;
        }
    }
}
#pragma mark - 返回上一页面的方法
- (void)back {
    [self.navigationController popViewControllerAnimated:YES];
}
#pragma mark  - 更多印象的点击方法
- (void)moreButtonClick {
    
    
    DestTravelNotesViewController *destTraveNotes = [[DestTravelNotesViewController alloc]init];
    destTraveNotes.getMyId =_pushToId;
    destTraveNotes.getMyType = _PushToType;
    [self.navigationController pushViewController:destTraveNotes animated:YES];
}

#pragma mark - 最大图的点击手势
- (void)destHostImageViewTap {
    DestPhotoesViewController *photoesViewController = [[DestPhotoesViewController alloc]init];
    photoesViewController.MyId = _MyId;
    photoesViewController.myType = _type;
    photoesViewController.cityName = _destNameString ;
    [self.navigationController pushViewController:photoesViewController animated:YES];
    
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
#pragma mark - alertView的大丽丽方法
-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
    if (buttonIndex == 1) {
        DestBasicModel *basicModel = [_destLastTableViewModelArryay objectAtIndex:5];
        NSMutableArray *lastArray = [[NSMutableArray alloc]init];
        NSArray *array= [basicModel.secondString componentsSeparatedByString:@" "];
        for (NSString *str in array) {
            NSArray *arr = [str componentsSeparatedByString:@"-"];
            [lastArray addObject:arr];
        }
        NSMutableArray *lastA = [[NSMutableArray alloc]init];
        for (NSArray *myArray in lastArray) {
            
            NSString *huhuStr =[myArray componentsJoinedByString:@""];
            [lastA addObject:huhuStr];
        }
        NSString *nsurlSt = [lastA componentsJoinedByString:@""];
        
        NSURL *url = [NSURL URLWithString:nsurlSt];
        if ([[UIApplication sharedApplication] canOpenURL:url]) {
            [[UIApplication sharedApplication] openURL:url];
        }
        else
        {
            UIAlertView *alertVieww = [[UIAlertView alloc] initWithTitle:@"号码不可用\n或您的备设不支持拨号功能" message:nil delegate:nil cancelButtonTitle:@"取消" otherButtonTitles:nil, nil];
            [alertVieww show];
            
        }
    }}
#pragma mark - 视图即将出现
- (void)viewWillAppear:(BOOL)animated {
    self.navigationController.navigationBar.alpha = YES;
    self.tabBarController.tabBar.hidden = YES;
    ///当回到 这个页面 判断navigation的透明度
    
    self.navigationController.navigationBarHidden = NO;
    if (_destTabelView.contentOffset.y > 236 *HEIGHT) {
        self.navigationController.navigationBar.alpha= (_destTabelView.contentOffset.y - 236) /64.;
        
    }else{
        self.navigationController.navigationBarHidden =  YES;
    }
    
}
#pragma mark - 第一个tabelView的头像的点击方法
- (void)imageViewtap:(UIButton *)sender {
    ///根据 tap取出iamgeView的tag值来判断点的是哪个cell上的头像
    
    
    DestImpressionModel *model = [_destImpressionsModelArray objectAtIndex:sender.tag];
    NSMutableDictionary *dic = model.trip;
    NSMutableDictionary *userDic = [dic objectForKey:@"user"];
    NSNumber *imageViewId = [userDic objectForKey:@"id"];
    RecUserViewController *rec = [[RecUserViewController alloc]init];
    rec.userId = imageViewId;
    
    [self.navigationController pushViewController:rec animated:YES];
    
}
- (void)iamgeViewButtonClick: (UIButton *)sender {
    DestImpressionSecondModel *secondModel = [_destReviewsModelArray objectAtIndex:sender.tag  - 10000];
    RecUserViewController *recuser = [[RecUserViewController alloc]init];
    NSMutableDictionary *dic = secondModel.user;
    NSNumber *imageViewId = [dic objectForKey:@"id"];
    recuser.userId = imageViewId;
    [self.navigationController  pushViewController:recuser animated:YES];
}
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
    if (_destTabelView == scrollView) {
        if (_destTabelView.contentOffset.y > 236 *HEIGHT) {
            self.navigationController.navigationBarHidden = NO;
            
            self.navigationController.navigationBar.alpha= (_destTabelView.contentOffset.y - 236 *HEIGHT) /64.* HEIGHT;
        }else{
            
            self.navigationController.navigationBar.alpha = (280 *HEIGHT - _destTabelView.contentOffset.y)/64.* HEIGHT;
            if (_destTabelView.contentOffset.y < 236. *HEIGHT) {
                self.navigationController.navigationBarHidden = YES;
            }
        }
    }
}
/*
 #pragma mark - Navigation
 
 // In a storyboard-based application, you will often want to do a little preparation before navigation
 - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
 // Get the new view controller using [segue destinationViewController].
 // Pass the selected object to the new view controller.
 }
 */

@end
